#
# Copyright 2009, Jeffrey Palm.
#

# Just a simple class to hold the parameters in one place.  It
# contains a port and host address on which we communicate.
class Config

  DEFAULT_PORT     = 1212
  DEFAULT_ADDR     = '127.0.0.1'
  DEFAULT_BASE_URL = 'http://jeffpalm.com/resumeapp/'

  attr_reader :port
  attr_reader :addr
  attr_reader :base_url
  
  def initialize(port,addr,base_url)
    @port     = port
    @addr     = addr
    @base_url = base_url
  end

  # Returns the default instance
  def self.default
    Config.new DEFAULT_PORT,DEFAULT_ADDR,DEFAULT_BASE_URL
  end

  # Returns a new instance, taking into account the arguments
  # The arguments are as follows:
  #   1. port
  #   2. addr
  #   3. base url
  def self.get_instance(args)
    if args.length == 0
      port = DEFAULT_PORT
      addr = DEFAULT_ADDR
      base = DEFAULT_BASE_URL
    elsif args.length == 1
      port = args[0]
      addr = DEFAULT_ADDR
      base = DEFAULT_BASE_URL
    elsif args.length == 2
      port = args[0]
      addr = args[1]
      base = DEFAULT_BASE_URL
    else
      port = args[0]
      addr = args[1]
      base = args[2]
    end
    Config.new port,addr,base
  end

end
